package com.szxy.miaosha.redis;

/**
 * @Auther:wzer
 * @Date:2020/9/6
 * @Description:com.szxy.miaosha.redis
 * @Version:1.0 抽象类模板
 **/
public abstract class BasePrefix implements KeyPrefix {

    /**
     * 过期时间
     */
    private int expireSeconds;

    /**
     * 前缀
     */
    private String prefix;

    public BasePrefix(int expireSeconds, String prefix) {
        this.expireSeconds = expireSeconds;
        this.prefix = prefix;
    }

    public BasePrefix(String prefix) {
        this.expireSeconds = 0;
        this.prefix = prefix;
    }

    @Override
    public int expireSeconds() {
        return this.expireSeconds;
    }

    @Override
    public String getPrefix() {
        return this.getClass().getSimpleName() + ":" + this.prefix;
    }
}
